package com.wanxi.web.controller;

import com.wanxi.product.service.api.query.shop.SkuQueryShop;
import com.wanxi.product.service.api.result.CommonResult;
import com.wanxi.product.service.api.vo.shop.SkuFindAllOutVo;
import com.wanxi.product.service.api.vo.shop.SkuFindByIdOutVo;
import com.wanxi.product.service.api.vo.shop.SkuShelvesInVo;
import com.wanxi.repertory.service.api.vo.RepertoryTotalUpdateInVo;
import com.wanxi.web.service.product.ProductShopWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: ShopProductController
 * Description: 店家商品
 * date: 2022/1/17 9:23
 *
 * @author lxl
 * @version 1.0
 * @since JDK 1.8
 */
@Api(tags = "店家商品接口")
@RestController
@RequestMapping("shop/product")
public class ShopProductController {

    @Resource
    private ProductShopWebService service;

    @ApiOperation("获取sku列表")
    @GetMapping("/sku/findAll")
    public CommonResult<List<SkuFindAllOutVo>> findAllSku(SkuQueryShop skuQuery) {
        return service.findAllSku(skuQuery);
    }

    @ApiOperation("根据id查找sku")
    @GetMapping("/sku/findById")
    public CommonResult<SkuFindByIdOutVo> findSkuById(Long skuId) {
        return service.findSkuById(skuId);
    }

    @ApiOperation("商品上下架")
    @PutMapping("/sku/shelve")
    public CommonResult skuOnShelvesAndOffShelves(SkuShelvesInVo skuShelvesInVo) {
        return service.skuOnShelvesAndOffShelves(skuShelvesInVo);
    }

    @ApiOperation("根据店铺id查找店铺下所有sku id")
    @GetMapping("/sku/findSkuIdByShopId")
    public com.wanxi.repertory.service.api.result.CommonResult<List<Long>> findSkuIdByShopId(Long shopId) {
        return service.findSkuIdByShopId(shopId);
    }

    @ApiOperation("修改库存量与商品状态")
    @PutMapping("/total/update")
    public com.wanxi.repertory.service.api.result.CommonResult updateTotal(RepertoryTotalUpdateInVo repertoryUpdateInVo) {
        return service.updateTotal(repertoryUpdateInVo);
    }
}
